//
//  LPPTabBarController.m
//  Lottery
//
//  Created by 刘盼 on 16/1/21.
//  Copyright © 2016年 lhheh. All rights reserved.
//

#import "LPPTabBarController.h"
#import "LPPTabBarView.h"
@interface LPPTabBarController ()<LPPTabBarViewDelegate>

@end

@implementation LPPTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIViewController *v1 = [self loadVcWithSBname:@"Hall"];
    UIViewController *v2 = [self loadVcWithSBname:@"Arena"];
    UIViewController *v3 = [self loadVcWithSBname:@"Discovery"];
    UIViewController *v4 = [self loadVcWithSBname:@"History"];
    UIViewController *v5 = [self loadVcWithSBname:@"MyLottery"];
    
    self.viewControllers = @[v1,v2,v3,v4,v5];
    
    LPPTabBarView *tabbar = [[LPPTabBarView alloc]init];
    
    tabbar.frame = self.tabBar.bounds;
    //代理
    tabbar.delegate = self;
    
    for (int i = 0; i < self.viewControllers.count; i++) {
        
        NSString *imageName = [NSString stringWithFormat:@"TabBar%d",i+1];
        
        NSString *imageSel = [NSString stringWithFormat:@"TabBar%dSel",i+1];
        
        [tabbar addButtonWithImage:imageName imagePress:imageSel];
    }
    
    [self.tabBar addSubview:tabbar];
    
}
#pragma mark-------代理跳转控制器-----------
-(void)tabBar:(LPPTabBarView *)tabbar WithIndex:(NSInteger)index{
    
    self.selectedIndex = index;
}
//添加子控制器
-(UIViewController *)loadVcWithSBname:(NSString *)name{
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:name bundle:nil];
    
    return storyboard.instantiateInitialViewController;
}


@end
